package com.jt.mall.common.entity;

import java.io.Serializable;

/**
 * @author wangning
 * @create 2021-12-24 15:46
 */
public class RspResult implements Serializable {
	private static final long serialVersionUID = 1L;
	private Boolean success;
	private Integer code;
	private String msg;
	private Object data;

	private RspResult() {}

	public static RspResult build() {
		return new RspResult();
	}

	public static RspResult build(Boolean success, Integer code, String msg) {
		return build(success, code, msg, null);
	}

	public static RspResult build(Boolean success, Integer code, Object data) {
		return build(success, code, null, data);
	}

	public static RspResult build(Boolean success, Integer code, String msg, Object data) {
		return new RspResult().setSuccess(success).setCode(code).setMsg(msg).setData(data);
	}

	public static RspResult ok() {
		return build(true, 200, null, null);
	}

	public static RspResult ok(String msg) {
		return build(true, 200, msg, null);
	}

	public static RspResult ok(Object data) {
		return build(true, 200, null, data);
	}

	public static RspResult ok(String msg, Object data) {
		return build(true, 200, msg, data);
	}

	public static RspResult error() {
		return build(false, 500, null, null);
	}

	public static RspResult error(String msg) {
		return build(false, 500, msg, null);
	}

	public static RspResult error(Integer code, String msg) {
		return build(false, code, msg, null);
	}

	public static RspResult error(String msg, Object data) {
		return build(false, 500, msg, data);
	}

	public static RspResult error(Integer code, String msg, Object data) {
		return build(false, code, msg, data);
	}

	public Boolean getSuccess() {
		return success;
	}

	public RspResult setSuccess(Boolean success) {
		this.success = success;
		return this;
	}

	public Integer getCode() {
		return code;
	}

	public RspResult setCode(Integer code) {
		this.code = code;
		return this;
	}

	public String getMsg() {
		return msg;
	}

	public RspResult setMsg(String msg) {
		this.msg = msg;
		return this;
	}

	public Object getData() {
		return data;
	}

	public RspResult setData(Object data) {
		this.data = data;
		return this;
	}
}
